/****************************************************************************
**
** Copyright (C) 2012 Róbert Márki
**
** This file is part of Web Feeds.
**
** Web Feeds is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Web Feeds is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Web Feeds.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.1
import "../../../../shared/qml" as Shared
import "../../../../shared/qml/UIConstants.js" as UIConstants
import "../misc" as Misc
import GoogleReader 1.0

Item {
    id: root

    signal released(int row)
    signal holded(int row)

    property int titleSize: UIConstants.LIST_TILE_SIZE
    property int titleWeight: Font.Bold
    property color titleColor: UIConstants.LIST_TITLE_COLOR

    property int subtitleSize: UIConstants.LIST_SUBTILE_SIZE
    property int subtitleWeight: Font.Light
    property color subtitleColor: UIConstants.LIST_SUBTITLE_COLOR

    property variant service
    height: UIConstants.DEFAULT_DELEGATE_HEIGHT
    width: parent.width

    BorderImage {
        id: background
        anchors.fill: parent
        // Fill page porders
        anchors.leftMargin: -UIConstants.DEFAULT_MARGIN
        anchors.rightMargin: -UIConstants.DEFAULT_MARGIN
        visible: mouseArea.pressed
        source: "image://theme/meegotouch-panel-background-pressed"
    }

    Shared.Separator {
        id: separator
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.leftMargin: UIConstants.DEFAULT_MARGIN
        anchors.right: parent.right
        anchors.rightMargin: UIConstants.DEFAULT_MARGIN
        visible: index
    }
    Item {
        id: conents
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.leftMargin: UIConstants.DEFAULT_MARGIN
        anchors.right: parent.right
        anchors.rightMargin: UIConstants.DEFAULT_MARGIN

        Label {
            id: title
            anchors.top: parent.top
            anchors.topMargin: UIConstants.DEFAULT_HALF_MARGIN
            anchors.left: parent.left
            anchors.right: parent.right
            text: model.title
            font.family: UIConstants.FONT_FAMILY
            font.weight: root.titleWeight
            font.pixelSize: root.titleSize
            textFormat: Text.PlainText
            color: root.titleColor
            elide: Text.ElideRight
            maximumLineCount: 1
        }
        Label {
            id: url
            anchors.bottom: parent.bottom
            anchors.bottomMargin: UIConstants.DEFAULT_HALF_MARGIN
            anchors.left: parent.left
            anchors.right: parent.right
            text: model.url
            font.pixelSize: UIConstants.FONT_LSMALL
            font.family: UIConstants.FONT_FAMILY_LIGHT
            color: "dimgray"
            elide: Text.ElideRight
            maximumLineCount: 1
        }
    }
    MouseArea {
        id: mouseArea;
        anchors.fill: parent
        onReleased: {
            if(!mouse.wasHeld)
                root.released(index);
        }
        onPressAndHold: {
            root.holded(index);
        }
    }
}
